<?php

/**
 * frontend actions.
 *
 * @package    yihai
 * @subpackage frontend
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class frontendActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    //首页幻灯
    $this->images = Doctrine::getTable('HomepageImage')
      ->createQuery('a')
	    ->orderBy('created_at desc')
	    ->limit(5)
      ->execute();

	$this->categorys = Doctrine::getTable('ArticleCategory');
	//艺海动态
	$this->latestid = $this->categorys->findOneByName("艺海动态")->getId();
	$this->latest = Doctrine::getTable('Article')->getArticleByCategory($this->latestid,10);

    //拍卖新闻
	$this->newsid = $this->categorys->findOneByName("拍卖新闻")->getId();
	$this->news = Doctrine::getTable('Article')->getArticleByCategory($this->newsid,10);

	//拍卖预告
	$this->forecasts = Doctrine::getTable('Article')->getArticleByCategory($this->categorys->findOneByName("拍卖预告")->getId(),10);

	//拍卖知识
	$this->lores = Doctrine::getTable('Article')->getArticleByCategory($this->categorys->findOneByName("拍卖知识")->getId(),5);
  

	//广告上
    $adtype1 = Doctrine::getTable('Adtype')
		->findOneByName("首页右侧上");
	$adtype1id=$adtype1->getId();
	
	$this->ad1 =Doctrine_Query::create()
				 ->from('Ad')
				 ->Where('adtype_id = ?', $adtype1id)
				 ->addWhere('is_valid = ?',true)
				 ->fetchOne();
	//广告下
    $adtype2 = Doctrine::getTable('Adtype')
		->findOneByName("首页右侧下");
	$adtype2id=$adtype2->getId();
	
	$this->ad2 =Doctrine_Query::create()
				 ->from('Ad')
				 ->Where('adtype_id = ?', $adtype2id)
				 ->addWhere('is_valid = ?',true)
				 ->fetchOne();

	//精彩照片
	$this->photos = Doctrine::getTable('Photo')
      ->createQuery('a')
      ->where('is_inhomepage = 1')
      ->orderBy('created_at desc')
      ->limit(5)
      ->execute();
    //友情链接
    $this->links = Doctrine::getTable('Link')
      ->createQuery('a')
      ->limit(5)
      ->execute();
  }
}
